from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import StringField, TextAreaField, FloatField, SubmitField, DateField, BooleanField, SelectField
from wtforms.validators import DataRequired, Length, NumberRange

class AdminThesisForm(FlaskForm):
    title = StringField('论文题目', validators=[
        DataRequired(message='题目不能为空'),
        Length(max=200, message='题目长度不能超过200个字符')
    ])
    description = TextAreaField('论文描述')
    programming_language = SelectField('编程语言', 
        choices=[
            ('', '请选择编程语言'),
            ('Python', 'Python'),
            ('Java', 'Java'),
            ('C++', 'C++'),
            ('C#', 'C#'),
            ('JavaScript', 'JavaScript'),
            ('PHP', 'PHP'),
            ('Go', 'Go'),
            ('MATLAB', 'MATLAB'),
            ('R', 'R'),
            ('其他', '其他')
        ],
        validators=[DataRequired(message='请选择编程语言')]
    )
    price = FloatField('预算', validators=[
        DataRequired(message='预算不能为空'),
        NumberRange(min=500, max=2050, message='预算必须在500-2050元之间')
    ])
    
    contact_info = StringField('联系方式', validators=[
        DataRequired(message='联系方式不能为空'),
        Length(max=100, message='联系方式长度不能超过100个字符')
    ])
    deadline = DateField('期望完成日期', validators=[
        DataRequired(message='请选择期望完成日期')
    ])
    need_environment = BooleanField('是否需要环境配置（+100元）')
    
    # 管理员额外字段
    status = SelectField('状态', choices=[
        ('pending', '待处理'),
        ('accepted', '已接受'),
        ('completed', '已完成')
    ])
    
    proposal_file = FileField('开题报告（选填）', validators=[
        FileAllowed(['pdf', 'doc', 'docx'], message='只允许上传 PDF 或 Word 文档')
    ])
    
    submit = SubmitField('提交') 